﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WeManageService;

namespace WeManageForm
{
	public partial class PlanFinishForm : Form
	{
		public Plan plan;

		public PlanFinishForm(Plan plan)
		{
			InitializeComponent();
			this.plan = plan;
			lblTitle.Text = plan.Name;
			TxtDescription.GotFocus += Global.EmptyHintTextBox_GotFocus;
			TxtDescription.LostFocus += Global.EmptyHintTextBox_LostFocus;
		}

		private void btnConfirm_Click(object sender, EventArgs e)
		{
			try
			{
				if (int.TryParse(txtScore.Text, out int score) && score > 0)
				{
					//plan.Score = score;
					//plan.PState = 1;
					//plan.Comment = TxtDescription.Text;
					//PlanManager.ModifyPlan(plan);
					PlanManager.FinishPlan(plan.PlanID, Global.GetEmptyHintTextBoxValue(TxtDescription), score);
					MessageBox.Show("任务已完成！", "");
					this.Close();
				}
				else
				{
					lblAlert.Text = "错误！分数必须是大于0的整数！";
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
    }
}
